/*
 *  $Id: WindHorn.cs 1060 2010-05-20 12:34:55Z thenn.erannor $
 *	This file is a part of Ragima CCG.
 *	(C) 2008-2009 Ragima development group.
 *
 *	Licensed under the terms of the GNU GPL License version 2.
 *
 */

namespace Ragima.Cards001.Air.Spells {
    public class WindHorn: SpellCard<UnionData> {
        public WindHorn() : base("001_a_s_wind_horn") {
            Level = CompleteLevel.ReadyForTest;
            Version = 0;
            Element = ElementType.Air;
            Value = 100;
            Target = new UnionTarget(GetTargetPhrase(), CreatureTarget.Own, LandTarget.Own);
            AddManaCost(3);
            AddManaCost(ElementType.Water, 2);
        }

        protected override void ManaCostAction(TargetArgs<UnionData> args, ElementValues manas) {
            TargetArgs<Creature> ca;
            if (args.Target.GetArgs(out ca))
                manas.Increment(Element, ca.Target.Health);
        }

        protected override void DoAction(TargetArgs<UnionData> args) {
            SummonedObject target = null;
            TargetArgs<Creature> ca;
            TargetArgs<Land> la;
            switch (args.Target.GetArgs(out ca, out la)) {
                case 1:
                    target = ca.Target;
                    break;
                case 2:
                    target = la.Target;
                    break;
            }
            if (target == null)
                return;

            foreach (EnchantmentAffect enchant in target.GetEnchantments()) {
                if (enchant.Caster != null) {
                    enchant.Caster = args.Player;
                    enchant.ReturnToHand();
                }
            }
            target.ReturnToHand();
        }
    }
}
